package com.qianhe.demo;

import com.github.qianhe.sdk.QHRead;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ReadServiceApi
 * @author Zhang Xingliang
 */
@Component
@Configuration
public class QHReadService {

    @Autowired
    private MyQHConfig config;
    /**
     * 验签 判断签名是否正确，必须包含sign字段，否则返回false。使用MD5签名。
     *
     * @param data Map类型数据
     * @return 签名是否正确
     * @throws Exception
     */
    public boolean verifySign(Map<String, String> data) throws Exception {
        return new QHRead(this.config).verifySign(data);
    }

    /**
     * 查询阅读任务列表
     *
     * @param data
     * @return Map<String, String>
     */
    public Map<String, Object> getTaskList(Map<String, String> data) throws Exception {
        return new QHRead(this.config).getTaskList(data);
    }

    /**
     * 一键领取
     *
     * @param data
     * @return Map<String, String>
     */
    public Map<String, Object> getReadTask(Map<String, String> data) throws Exception {
        return new QHRead(this.config).getReadTask(data);
    }
    /**
     * 更新异步任务完成通知地址
     *
     * @param data
     * @return Map<String, String>
     */
    public Map<String, Object> updateNotifyUrl(Map<String, String> data) throws Exception {
        return new QHRead(this.config).updateNotifyUrl(data);
    }

}
